package acm.pta2;

import java.util.*;

class Person {
    int id;
    double money;
    int count;

    public Person(int id, double money, int count) {
        this.id = id;
        this.money = money;
        this.count = count;
    }
}

public class T9 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        Person[] people = new Person[N + 1];
        for (int i = 1; i <= N; i++) {
            people[i] = new Person(i, 0, 0);
        }
        for (int i = 1; i <= N; i++) {
            int K = scanner.nextInt();
            for (int j = 0; j < K; j++) {
                int Ni = scanner.nextInt();
                int Pi = scanner.nextInt();
                people[Ni].money += Pi / 100.0;
                people[Ni].count++;
                people[i].money -= Pi / 100.0;
            }
        }
        Arrays.sort(people, 1, N + 1, new Comparator<Person>() {
            @Override
            public int compare(Person o1, Person o2) {
                if (o1.money != o2.money) {
                    return Double.compare(o2.money, o1.money);
                } else if (o1.count != o2.count) {
                    return o2.count - o1.count;
                } else {
                    return o1.id - o2.id;
                }
            }
        });
        for (int i = 1; i <= N; i++) {
            System.out.printf("%d %.2f\n", people[i].id, people[i].money);
        }
    }
}
